<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>异步编程</title>
</head>

<body>
    <h1>异步编程具体执行的地方就是回调函数</h1>
    <div>
        <div>kkkk</div>
        <div>kkkk</div>
        <div>kkkk</div>
        <div>kkkk</div>
    </div>
    <div>sdfsdfsdfsd</div>
    <!-- <script>

        function getName() {
            return 'klz';
        }

        // javascript 是单线程
        // A    
        setTimeout(function (data) {
            console.log("1111111")

            this.mesageList = data.ddd;
            // data.name
            setTimeout(function(){
                setTimeout(function() {

                },10000)
            },2000)

        }, 3000)


        // 1. Promise 2.async await

        let aa = new Promise(function(resolve,reject){
            setTimeout(function(data){
                resolve(data)
            },1000)
        });

        aa.then(function(data) {

        })

        async function getMessage(){
            setTimeout(function(data){
                resolve(data)
            },1000)
        }

        let res = await getMessage();
        if(res.data.code === 0){

        }


        console.log("22222")
        console.log("22222")
        console.log("22222")
        console.log("22222")
        console.log("22222")
        console.log("22222")
        console.log("22222")
        console.log("22222")
        console.log("22222")

        // http 同步 3s

        // 异步 http  B 3s

        // kkkk

        // 代码.....
    </script> -->
    <script>
        let list = [
            {
                name: '累计收益榜'
            },
            {
                name: '月收益榜'
            },
        ]

        let index = list.findIndex(function (item) {
            return item.name === '日收益榜'
        })
        console.log(index)
    </script>
</body>

</html>